# -*- coding: utf-8 -*-

# To change this template, choose Tools | Templates
# and open the template in the editor.

__author__="Eagle"
__date__ ="$28.2.2011 23:09:40$"

import wx
import GUI.gui as gui
from controllers.books import BooksController
from controllers.notes import NotesController
from controllers.main import MainController
import helpers.tabcontainer
import helpers.modulemanager
import helpers.dbmanager

class MyApp(wx.App):
    def OnInit(self):
        frame = gui.frame_main(None)
        frame.Show(True)

        tabs = helpers.tabcontainer.TabContainer.getInstance("main")
        tabs.addPanel("book")
        tabs.addPanel("notes")
        tabs.addPanel("note")

        moduleMgr = helpers.modulemanager.ModuleManager.getInstance()

        mainCtrl = MainController(frame)

        bookCtrl = BooksController(frame)
        notesCtrl = NotesController(frame, bookCtrl)
        bookCtrl.setNotesController(notesCtrl)

        moduleMgr.Register("main", mainCtrl.model, mainCtrl.view, mainCtrl)
        moduleMgr.Register("books", bookCtrl.model, bookCtrl.view, bookCtrl)
        moduleMgr.Register("notes", notesCtrl.model, notesCtrl.view, notesCtrl)

        mainCtrl.initAction()
        bookCtrl.initAction()
        notesCtrl.initAction()

        mainCtrl.loginAction()


        return True

app = MyApp(False)
app.MainLoop()